package cn.com.huzo.repository.tech.impl;

import cn.com.huzo.model.entities.tech.PieceYardageLinesEntity;
import cn.com.huzo.model.entities.tech.PieceYardageLinesSizeGradeEntity;
import cn.com.huzo.repository.tech.PieceYardageLinesSizeGradeRepository;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 尺码单用量数据对象实现。
 *
 * @author 吴旭
 */
@Repository("PieceYardageLinesSizeGradeRepository")
public class PieceYardageLinesSizeGradeRepositoryImpl extends GenericRepositoryImpl<PieceYardageLinesSizeGradeEntity, String>
        implements PieceYardageLinesSizeGradeRepository {

    private final String namespace = "cn.com.huzo.repository.tech.PieceYardageLinesSizeGradeRepository";

    /**
     * 构造函数,设置the entity to UcLinesRepositoryImpl.class.
     */
    public PieceYardageLinesSizeGradeRepositoryImpl() {
        super(PieceYardageLinesSizeGradeEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<PieceYardageLinesSizeGradeEntity> fetchByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderKey"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insert(List<PieceYardageLinesSizeGradeEntity> itemList) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insertLinesFromClipboard(Long headerId, String copiedLinesId) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("CopiedLinesId", copiedLinesId);

        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insertLinesFromClipboard"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer importLinesFromOtherBom(Long headerId, Long importedBomHeaderId) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("ImportedBomHeaderId", importedBomHeaderId);

        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "importLinesFromOtherBom"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer updateParentLinesIdForImportedLines(Long headerId) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);

        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "updateParentLinesIdForImportedLines"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteByParentLinesId(String parentLinesId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteByParentLinesKey"), parentLinesId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchClearLinesSizePieceYardage(List<PieceYardageLinesEntity> itemList) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchClearLinesSizePieceYardage"), itemList);
    }
}
